﻿/*
 * Copyright © 2020, Wuxi Safover Intelligent Technology Co., Ltd. All rights reserved.
 * 
 * 无锡安永智能科技有限公司版权所有，未经许可，不得用于商业用途
 * 
 * Visit: https://www.safover.com/ 
 */

using SciChart.Charting.ChartModifiers;
using SafoverWpfFw;
using System.Windows.Input;

namespace Safover.LidarCollector.ViewModel
{
    public class ChartControlViewModel : BaseViewModel
    {
        private ZoomExtentsModifier ZoomExtentsModifier { get; } = new ZoomExtentsModifier
        {
            IsAnimated = true,
        };

        private RubberBandXyZoomModifier RubberBandXyZoomModifier { get; } = new RubberBandXyZoomModifier();

        private MouseWheelZoomModifier MouseWheelZoomModifier { get; } = new MouseWheelZoomModifier();

        private ZoomPanModifier ZoomPanModifier { get; } = new ZoomPanModifier
        {
            ExecuteOn = ExecuteOn.MouseRightButton
        };


        public ModifierGroup ModifierGroup { get; set; }

        private bool enableRubberBandXyZoomModifier;
        public bool EnableRubberBandXyZoomModifier
        {
            get => enableRubberBandXyZoomModifier;
            set
            {
                enableRubberBandXyZoomModifier = value;

                if (value)
                {
                    ModifierGroup.ChildModifiers.Add(RubberBandXyZoomModifier);
                }
                else
                {
                    _ = ModifierGroup.ChildModifiers.Remove(RubberBandXyZoomModifier);
                }
            }
        }

        private bool enableMouseWheelZoomModifier;
        public bool EnableMouseWheelZoomModifier
        {
            get => enableMouseWheelZoomModifier;
            set
            {
                enableMouseWheelZoomModifier = value;

                if (value)
                {
                    ModifierGroup.ChildModifiers.Add(MouseWheelZoomModifier);
                }
                else
                {
                    _ = ModifierGroup.ChildModifiers.Remove(MouseWheelZoomModifier);
                }
            }
        }

        private bool enableZoomPanModifier;
        public bool EnableZoomPanModifier
        {
            get => enableZoomPanModifier;
            set
            {
                enableZoomPanModifier = value;

                if (value)
                {
                    ModifierGroup.ChildModifiers.Add(ZoomPanModifier);
                }
                else
                {
                    _ = ModifierGroup.ChildModifiers.Remove(ZoomPanModifier);
                }
            }
        }

       

        /// <summary>
        /// 返回初始显示值
        /// </summary>
        public ICommand ZoomOutCommand { get; }

        public ChartControlViewModel()
        {
            ModifierGroup = new ModifierGroup();

            ModifierGroup.ChildModifiers.Add(ZoomExtentsModifier);

            ZoomOutCommand = new RelayCommand(() => ZoomExtentsModifier.OnModifierDoubleClick(new SciChart.Core.Utility.Mouse.ModifierMouseArgs()));
        }
    }

    
}